package gui;

import javax.swing.JFrame;
import javax.swing.JOptionPane;


public class MainForm extends javax.swing.JFrame {

    /**
     * Creates new form MainJFrame
     */
    public MainForm() {
        initComponents();
        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
        setLocationRelativeTo(null);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mdiPane = new javax.swing.JDesktopPane();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        artistsMenuItem = new javax.swing.JMenuItem();
        musicGroupsMenuItem = new javax.swing.JMenuItem();
        musicGroupAlbumsMenuItem = new javax.swing.JMenuItem();
        artistAlbumsMenuItem = new javax.swing.JMenuItem();
        playlistsMenu = new javax.swing.JMenu();
        exitMenu = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("KLM RadioStation");
        setMinimumSize(new java.awt.Dimension(600, 400));
        setName("mainFrame"); // NOI18N
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        mdiPane.setAutoscrolls(true);

        javax.swing.GroupLayout mdiPaneLayout = new javax.swing.GroupLayout(mdiPane);
        mdiPane.setLayout(mdiPaneLayout);
        mdiPaneLayout.setHorizontalGroup(
            mdiPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 856, Short.MAX_VALUE)
        );
        mdiPaneLayout.setVerticalGroup(
            mdiPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 453, Short.MAX_VALUE)
        );

        fileMenu.setText("Διαχείριση Αρχείων");

        artistsMenuItem.setText("Καλλιτέχνες");
        artistsMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                artistsMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(artistsMenuItem);

        musicGroupsMenuItem.setText("Συγκροτήματα");
        musicGroupsMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                musicGroupsMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(musicGroupsMenuItem);

        musicGroupAlbumsMenuItem.setText("Άλμπουμ Συγκροτημάτων");
        musicGroupAlbumsMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                musicGroupAlbumsMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(musicGroupAlbumsMenuItem);

        artistAlbumsMenuItem.setText("Άλμπουμ Καλλιτεχνών");
        artistAlbumsMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                artistAlbumsMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(artistAlbumsMenuItem);

        menuBar.add(fileMenu);

        playlistsMenu.setText("Λίστες Τραγουδιών");
        playlistsMenu.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                playlistsMenuMouseClicked(evt);
            }
        });
        menuBar.add(playlistsMenu);

        exitMenu.setText("Έξοδος");
        exitMenu.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                exitMenuMouseClicked(evt);
            }
        });
        menuBar.add(exitMenu);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(mdiPane)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(mdiPane)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void exitMenuMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_exitMenuMouseClicked
        dispatchEvent(new java.awt.event.WindowEvent(this, java.awt.event.WindowEvent.WINDOW_CLOSING));
    }//GEN-LAST:event_exitMenuMouseClicked

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        String options[] = { "Έξοδος", "Άκυρο" };
        JFrame frame = (JFrame)evt.getSource();
        int choice = JOptionPane.showOptionDialog(
                               frame,
                               "Είστε σίγουρος ότι επιθυμείτε το κλείσιμο της εφαρμογής;",
                               "Κλείσμο Εφαρμογής",
                               JOptionPane.YES_NO_OPTION,
                               JOptionPane.QUESTION_MESSAGE,
                               null,
                               options,
                               "Έξοδος");
        if (choice == JOptionPane.YES_OPTION) {
            System.exit(0);
        }
    }//GEN-LAST:event_formWindowClosing

    private void playlistsMenuMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_playlistsMenuMouseClicked
        PlaylistsForm child = new PlaylistsForm();
        mdiPane.add(child);
        child.setVisible(true);
    }//GEN-LAST:event_playlistsMenuMouseClicked

    private void artistsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_artistsMenuItemActionPerformed
        ArtistsForm child = new ArtistsForm();
        mdiPane.add(child);
        child.setVisible(true);
    }//GEN-LAST:event_artistsMenuItemActionPerformed

    private void musicGroupsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_musicGroupsMenuItemActionPerformed
        MusicGroupsForm child = new MusicGroupsForm();
        mdiPane.add(child);
        child.setVisible(true);
    }//GEN-LAST:event_musicGroupsMenuItemActionPerformed

    private void musicGroupAlbumsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_musicGroupAlbumsMenuItemActionPerformed
        MusicGroupAlbumsForm child = new MusicGroupAlbumsForm();
        mdiPane.add(child);
        child.setVisible(true);
    }//GEN-LAST:event_musicGroupAlbumsMenuItemActionPerformed

    private void artistAlbumsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_artistAlbumsMenuItemActionPerformed
        ArtistAlbumsForm child = new ArtistAlbumsForm();
        mdiPane.add(child);
        child.setVisible(true);
    }//GEN-LAST:event_artistAlbumsMenuItemActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem artistAlbumsMenuItem;
    private javax.swing.JMenuItem artistsMenuItem;
    private javax.swing.JMenu exitMenu;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JDesktopPane mdiPane;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenuItem musicGroupAlbumsMenuItem;
    private javax.swing.JMenuItem musicGroupsMenuItem;
    private javax.swing.JMenu playlistsMenu;
    // End of variables declaration//GEN-END:variables
}
